package com.wicture.erp4android.fragment;

import com.wicture.erp4android.R;

import android.app.Activity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;


/**
 * 功能页面载体，加载不同功能页面
 * @author Administrator
 *
 */
public class ContentFragment extends MyBaseFragment {

	private View view;
	private ViewSetter setter;
	private FrameLayout functions;
	private View childView;
	public ContentFragment(Activity act){
		this.mActivity = act;
	}
	
	/**
	 * 初始化界面
	 */
	@Override
	public View initView() {
		System.out.println("初始化了");
	view = View.inflate(mActivity, R.layout.fragment_content, null);
	functions = (FrameLayout) view.findViewById(R.id.fl_contentFragment);
		if(setter!=null){
			childView = setter.setView();
			if(functions.getChildCount()>0){
				functions.removeAllViews();
			}
			functions.addView(childView);
		}
		System.out.println(view+"调试");
		 return view;
	}

	@Override
	public void initData() {
		

	} 
	
	/**
	 * 设置监听，设置布局
	 * @param listenner
	 */
public void setView(ViewSetter listenner){
	setter = listenner;
}
	
	
	public interface ViewSetter{
		public View setView();
	}

	/**
	 * 设置标题
	 * @param text
	 */
	public void setTitile(String text){
		TextView title = (TextView) view.findViewById(R.id.tv_title);
		title.setText(text);
	}
	
	/**
	 * 切换页面
	 * @param view
	 */
	public void changeView(View view){
		//先清空页面
		if(functions.getChildCount()>0){
			functions.removeAllViews();
		}
		functions.addView(view);
	}
}
